package com.eb.dao;

import com.eb.pojo.MiaoshaGoods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Map;

public interface MiaoshaGoodsDao extends JpaRepository<MiaoshaGoods,Long> {
    @Query(value = "SELECT ms.*,g.goods_name,g.goods_img,g.goods_price FROM miaosha_goods ms  LEFT JOIN goods g on ms.goods_id=g.id WHERE g.goods_name LIKE ?1 and ms.start_date>=?2 and ms.end_date<=?3",nativeQuery = true,countQuery = "select count(*) from(SELECT ms.*,g.goods_name ,g.goods_img,g.goods_price FROM miaosha_goods ms LEFT JOIN goods g on ms.goods_id=g.id WHERE g.goods_name LIKE ?1 and ms.start_date>=?2 and ms.end_date<=?3)abc")
    Page<Map<String, Object>> miaoshaGoods(String s, String start, String end, Pageable of);
}
